﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;

namespace WindowsForms.ThuQuy
{
    public partial class FormChiTietBaoCao : Form
    {
        Bitmap bm;
        Font fontPrint;
        public FormChiTietBaoCao()
        {
            InitializeComponent();
        }

        private void lblTenBaoCao_TextChanged(object sender, EventArgs e)
        {
            
        }

        public void Print(Bitmap data)
        {
            PrintDocument print = new PrintDocument();
            fontPrint = new Font("Arial", 12);
            print.PrintPage += new PrintPageEventHandler(print_PrintPage);
            print.DefaultPageSettings.Landscape = true;
            print.Print();
        }


        private void printToolStripButton_Click(object sender, EventArgs e)
        {
            Print(bm);
        }

        public void print_PrintPage(object sender,PrintPageEventArgs e)
        {
            bm = new Bitmap(gbBaoCao.Width, gbBaoCao.Height);
            gbBaoCao.DrawToBitmap(bm, gbBaoCao.ClientRectangle);
            e.Graphics.DrawImage(bm, new Point(5, 5));
        }

        private void ThoattoolStripButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
